.class public Lcn/sharesdk/system/text/a;
.super Ljava/lang/Object;


# static fields
.field private static a:Lcn/sharesdk/system/text/a;


# instance fields
.field private b:Landroid/content/Context;


# direct methods
.method public constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method private a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Landroid/content/Intent;
    .registers 9

    new-instance v1, Landroid/content/Intent;

    const-string v0, "android.intent.action.SEND_MSG"

    invoke-direct {v1, v0}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const-string v0, "address"

    invoke-virtual {v1, v0, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v0, 0x10000000

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    const-string v0, "android.intent.extra.SUBJECT"

    invoke-virtual {v1, v0, p2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const-string v0, "sms_body"

    invoke-virtual {v1, v0, p3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const-string v0, "text/plain"

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

    invoke-virtual {p4}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-static {}, Ljava/net/URLConnection;->getFileNameMap()Ljava/net/FileNameMap;

    move-result-object v0

    invoke-interface {v0, v2}, Ljava/net/FileNameMap;->getContentTypeFor(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_34

    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v3

    if-gtz v3, :cond_46

    :cond_34
    invoke-virtual {v2}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v0

    const-string v2, "png"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_53

    const-string v0, "image/png"

    :cond_46
    :goto_46
    const-string v2, "android.intent.extra.STREAM"

    invoke-static {p4}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

    return-object v1

    :cond_53
    const-string v2, "jpg"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_63

    const-string v2, "jpeg"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_66

    :cond_63
    const-string v0, "image/jpeg"

    goto :goto_46

    :cond_66
    const-string v2, "gif"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_71

    const-string v0, "image/gif"

    goto :goto_46

    :cond_71
    const-string v0, "*/*"

    goto :goto_46
.end method

.method public static a(Landroid/content/Context;)Lcn/sharesdk/system/text/a;
    .registers 2

    sget-object v0, Lcn/sharesdk/system/text/a;->a:Lcn/sharesdk/system/text/a;

    if-nez v0, :cond_b

    new-instance v0, Lcn/sharesdk/system/text/a;

    invoke-direct {v0}, Lcn/sharesdk/system/text/a;-><init>()V

    sput-object v0, Lcn/sharesdk/system/text/a;->a:Lcn/sharesdk/system/text/a;

    :cond_b
    sget-object v0, Lcn/sharesdk/system/text/a;->a:Lcn/sharesdk/system/text/a;

    iput-object p0, v0, Lcn/sharesdk/system/text/a;->b:Landroid/content/Context;

    sget-object v0, Lcn/sharesdk/system/text/a;->a:Lcn/sharesdk/system/text/a;

    return-object v0
.end method

.method private a(Ljava/io/File;)Ljava/io/File;
    .registers 12

    const-wide/high16 v8, 0x3ff0000000000000L

    invoke-virtual {p1}, Ljava/io/File;->length()J

    move-result-wide v0

    long-to-double v0, v0

    const-wide v2, 0x41dfffffffc00000L

    div-double/2addr v0, v2

    sub-double/2addr v0, v8

    :cond_e
    const-string v2, "mms_tmp_file.jpg"

    new-instance v3, Ljava/io/File;

    invoke-virtual {p1}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v4

    invoke-direct {v3, v4, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    invoke-virtual {v3}, Ljava/io/File;->exists()Z

    move-result v2

    if-eqz v2, :cond_22

    invoke-virtual {v3}, Ljava/io/File;->delete()Z

    :cond_22
    invoke-virtual {v3}, Ljava/io/File;->createNewFile()Z

    add-double/2addr v0, v8

    invoke-static {v0, v1}, Ljava/lang/Math;->ceil(D)D

    move-result-wide v4

    double-to-int v2, v4

    invoke-static {p1, v2}, Lcn/sharesdk/framework/utils/R;->getBitmap(Ljava/io/File;I)Landroid/graphics/Bitmap;

    move-result-object v2

    if-eqz v2, :cond_37

    invoke-virtual {v2}, Landroid/graphics/Bitmap;->isRecycled()Z

    move-result v4

    if-eqz v4, :cond_3f

    :cond_37
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "Failed to compress image file"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_3f
    new-instance v4, Ljava/io/FileOutputStream;

    invoke-direct {v4, v3}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    sget-object v5, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat;

    const/16 v6, 0x64

    invoke-virtual {v2, v5, v6, v4}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z

    invoke-virtual {v4}, Ljava/io/FileOutputStream;->flush()V

    invoke-virtual {v4}, Ljava/io/FileOutputStream;->close()V

    if-eqz v2, :cond_5c

    invoke-virtual {v2}, Landroid/graphics/Bitmap;->isRecycled()Z

    move-result v4

    if-nez v4, :cond_5c

    invoke-virtual {v2}, Landroid/graphics/Bitmap;->recycle()V

    :cond_5c
    invoke-virtual {v3}, Ljava/io/File;->length()J

    move-result-wide v4

    const-wide/32 v6, 0x7fffffff

    cmp-long v2, v4, v6

    if-gtz v2, :cond_e

    return-object v3
.end method

.method private b(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Landroid/content/Intent;
    .registers 9

    new-instance v1, Landroid/content/Intent;

    const-string v0, "android.intent.action.SEND"

    const-string v2, "mms://"

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v2

    invoke-direct {v1, v0, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

    const-string v0, "address"

    invoke-virtual {v1, v0, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v0, 0x10000000

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    if-eqz p2, :cond_1e

    const-string v0, "android.intent.extra.SUBJECT"

    invoke-virtual {v1, v0, p2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    :cond_1e
    if-eqz p3, :cond_2f

    const-string v0, "sms_body"

    invoke-virtual {v1, v0, p3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const-string v0, "android.intent.extra.TEXT"

    invoke-virtual {v1, v0, p3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const-string v0, "text/plain"

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

    :cond_2f
    invoke-virtual {p4}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-static {}, Ljava/net/URLConnection;->getFileNameMap()Ljava/net/FileNameMap;

    move-result-object v0

    invoke-interface {v0, v2}, Ljava/net/FileNameMap;->getContentTypeFor(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_43

    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v3

    if-gtz v3, :cond_55

    :cond_43
    invoke-virtual {v2}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v0

    const-string v2, "png"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_62

    const-string v0, "image/png"

    :cond_55
    :goto_55
    const-string v2, "android.intent.extra.STREAM"

    invoke-static {p4}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    invoke-virtual {v1, v0}, Landroid/content/Intent;->setType(Ljava/lang/String;)Landroid/content/Intent;

    return-object v1

    :cond_62
    const-string v2, "jpg"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_72

    const-string v2, "jpeg"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_75

    :cond_72
    const-string v0, "image/jpeg"

    goto :goto_55

    :cond_75
    const-string v2, "gif"

    invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_80

    const-string v0, "image/gif"

    goto :goto_55

    :cond_80
    const-string v0, "*/*"

    goto :goto_55
.end method


# virtual methods
.method public a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcn/sharesdk/system/text/ActionListener;)V
    .registers 14

    const/4 v1, 0x0

    const/4 v0, 0x1

    if-eqz p4, :cond_f

    new-instance v2, Ljava/io/File;

    invoke-direct {v2, p4}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_65

    :cond_f
    :try_start_f
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "smsto:"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v2

    new-instance v3, Landroid/content/Intent;

    const-string v4, "android.intent.action.SENDTO"

    invoke-direct {v3, v4, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

    const-string v2, "sms_body"

    invoke-virtual {v3, v2, p3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v2, 0x10000000

    invoke-virtual {v3, v2}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    iget-object v2, p0, Lcn/sharesdk/system/text/a;->b:Landroid/content/Context;

    invoke-virtual {v2, v3}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_3c
    .catch Ljava/lang/Throwable; {:try_start_f .. :try_end_3c} :catch_5d

    :goto_3c
    if-eqz v0, :cond_5c

    if-eqz p5, :cond_5c

    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    const-string v1, "address"

    invoke-virtual {v0, v1, p1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    const-string v1, "subject"

    invoke-virtual {v0, v1, p2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    const-string v1, "body"

    invoke-virtual {v0, v1, p3}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    const-string v1, "image"

    invoke-virtual {v0, v1, p4}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    invoke-interface {p5, v0}, Lcn/sharesdk/system/text/ActionListener;->onStart(Ljava/util/HashMap;)V

    :cond_5c
    :goto_5c
    return-void

    :catch_5d
    move-exception v0

    if-eqz p5, :cond_63

    invoke-interface {p5, v0}, Lcn/sharesdk/system/text/ActionListener;->onError(Ljava/lang/Throwable;)V

    :cond_63
    move v0, v1

    goto :goto_3c

    :cond_65
    new-instance v2, Ljava/io/File;

    invoke-direct {v2, p4}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    const-wide/32 v4, 0x7fffffff

    invoke-virtual {v2}, Ljava/io/File;->length()J

    move-result-wide v6

    cmp-long v3, v4, v6

    if-gtz v3, :cond_79

    :try_start_75
    invoke-direct {p0, v2}, Lcn/sharesdk/system/text/a;->a(Ljava/io/File;)Ljava/io/File;
    :try_end_78
    .catch Ljava/lang/Throwable; {:try_start_75 .. :try_end_78} :catch_a6

    move-result-object v2

    :cond_79
    :try_start_79
    invoke-direct {p0, p1, p2, p3, v2}, Lcn/sharesdk/system/text/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Landroid/content/Intent;

    move-result-object v3

    iget-object v4, p0, Lcn/sharesdk/system/text/a;->b:Landroid/content/Context;

    invoke-virtual {v4, v3}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_82
    .catch Ljava/lang/Throwable; {:try_start_79 .. :try_end_82} :catch_83

    goto :goto_3c

    :catch_83
    move-exception v3

    :try_start_84
    invoke-direct {p0, p1, p2, p3, v2}, Lcn/sharesdk/system/text/a;->b(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Landroid/content/Intent;

    move-result-object v3

    const-string v4, "com.android.mms"

    invoke-virtual {v3, v4}, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;

    iget-object v4, p0, Lcn/sharesdk/system/text/a;->b:Landroid/content/Context;

    invoke-virtual {v4, v3}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_92
    .catch Ljava/lang/Throwable; {:try_start_84 .. :try_end_92} :catch_93

    goto :goto_3c

    :catch_93
    move-exception v3

    :try_start_94
    invoke-direct {p0, p1, p2, p3, v2}, Lcn/sharesdk/system/text/a;->b(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Landroid/content/Intent;

    move-result-object v2

    iget-object v3, p0, Lcn/sharesdk/system/text/a;->b:Landroid/content/Context;

    invoke-virtual {v3, v2}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
    :try_end_9d
    .catch Ljava/lang/Throwable; {:try_start_94 .. :try_end_9d} :catch_9e

    goto :goto_3c

    :catch_9e
    move-exception v0

    if-eqz p5, :cond_a4

    invoke-interface {p5, v0}, Lcn/sharesdk/system/text/ActionListener;->onError(Ljava/lang/Throwable;)V

    :cond_a4
    move v0, v1

    goto :goto_3c

    :catch_a6
    move-exception v0

    if-eqz p5, :cond_5c

    invoke-interface {p5, v0}, Lcn/sharesdk/system/text/ActionListener;->onError(Ljava/lang/Throwable;)V

    goto :goto_5c
.end method
